package com.abel.demo.services.impl;

import com.abel.demo.dao.master.UserInfoModelDao;
import com.abel.demo.dao.BaseDao;
import com.abel.demo.model.AddressModel;
import com.abel.demo.model.UserInfoModel;
import com.abel.demo.model.UserInfoModelCriteria;
import com.abel.demo.services.AddressService;
import com.abel.demo.services.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* @author abel.lin
* @date_time 2018-07-11 18:26
* @description
*/
@Service
public class UserInfoServiceImpl
    extends BaseServiceImpl<BaseDao<UserInfoModel,UserInfoModelCriteria>,UserInfoModel,UserInfoModelCriteria>
    implements UserInfoService {

    @Autowired
    private UserInfoModelDao userInfoModelDao;
    @Autowired
    private AddressService addressService;

    public UserInfoServiceImpl(){
        super.baseMapper = userInfoModelDao;
    }

    /**
     * @author: Abel.lin
     * @date: 2018/7/12 17:13
     * @description: 测试事务
     * @return:
     */
    @Transactional
    @Override
    public void testTransactional() {
        UserInfoModel user = new UserInfoModel();
        user.setUserName("abel");
        insertSelective(user);

        AddressModel address = new AddressModel();
        address.setUserName("abel");
        address.setProvince("广东");
        address.setCity("深圳");
        address.setDistrict("南山");
        addressService.insertSelective(address);

//        int i = 1/0;  //除0异常用于测试事务

    }
}
